package cz.cernilovsky.android.profileapp.model;

import android.content.Context;
import android.net.wifi.WifiManager;

public class WiFiAction extends Action {
	public WiFiAction(Operation typeOfAction) {
		super(typeOfAction);
	}

	@Override
	public boolean perform(Context context) {
		if(operation != Operation.NOOP) {
			WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
			if((wm.isWifiEnabled() && operation == Operation.OFF) || (!wm.isWifiEnabled() && operation == Operation.ON)) { 
				wm.setWifiEnabled(operation == Operation.ON);
				return true;
			}
		}
		return false;
	}

}
